#include<iostream>
#include<vector>
#include<string>
using namespace std;

class Solution {
    vector<int> solveStr(string& str)
    {
        int len = str.size();
        vector<int> ans;
        int posi = 0;
        while (posi < len) {
            while (str[posi] == '0') {
                posi++;
            }
            int tmpDigit = 0;
            while (posi < len && str[posi] != '.') {
                tmpDigit *= 10;
                tmpDigit += str[posi] - '0';
                posi++;
            }
            ans.push_back(tmpDigit);
            posi++;
        }
        return ans;
    }
public:
    int compareVersion(string version1, string version2) {
        vector<int> varr1 = solveStr(version1);
        vector<int> varr2 = solveStr(version2);
        int len1 = varr1.size(); int len2 = varr2.size();
        int posi = 0;
        // for(int i = 0;i < varr1.size();i++){
        //     cout << varr1[i] << " ";
        // }
        // cout << endl;
        // for(int i = 0;i < varr2.size();i++){
        //     cout << varr2[i] << " ";
        // }
        while (posi < len1 && posi < len2) {
            if (varr1[posi] < varr2[posi]) return -1;
            else if (varr1[posi] > varr2[posi]) return 1;
            posi++;
        }
        while (posi < len1) {
            if (varr1[posi]) return 1;
            posi++;
        }
        while (posi < len2) {
            if (varr2[posi]) return -1;
            posi++;
        }
        return 0;
    }
};